home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Help !!!!! on 'strstr"
- Date: 14 Mar 1996 15:46:18 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar14084618@qcd.lanl.gov>
- References: <314703FF.4045@msmail.st.stems.com> <jodellDo7097.Bto@netcom.com>
- <TANMOY.96Mar13090926@qcd.lanl.gov> <3147C7AC.6EE3@hsc.unt.edu>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: Steve Fogoros's message of Wed, 13 Mar 1996 23:15:56 -0800
-
- In article <3147C7AC.6EE3@hsc.unt.edu>
- Steve Fogoros <sfogoros@hsc.unt.edu> writes:
-
- SF: Tanmoy Bhattacharya wrote:
- SF:
- SF: > Any user function whose name begins with `is' followed by a lower case
- SF: > letter violates the ANSI C standard.
- SF:
- SF: You mentioned the same kind of violation regarding user functions that start with
- SF: 'str' followed by lower case letter in another post. I apologize that I question
- SF: this without being intimately familiar with ANSI C Standard. I am having a hard time
- SF: believing the standard would consider my use of other than reserved words a violation.
-
- Belief depends on experience :-) As a fortran programmer, I had hard
- time believing that a language _can_ have reserved words.
-
- This is the name space issue: many implementations cannot link code
- which defines the same names as in any standard library. The standard
- makes a guarantee that the standard library shall not define or use
- arbitrary names so that programs which follow the namespace rules in
- the standard are portable. Thus, for example, if I name a function
- `read', it cannot conflict with a library function name on any ANSI C
- implementation where such conflict would cause a problem.
-
- Some names are exempt from this guarantee (i.e. they do not belong to
- the user name space). These typically start with underscores (the
- detailed rules depend on exactly what context they are being used in),
- but in addition, for symbols with external linkage, they include the
- names of all library routines defined in the standard. Thus, for
- example, you cannot name your routine `fprintf'. To allow for
- extensions, some names are reserved in exactly the same way as
- existing library functions (such as those beginning with `is' and a
- lower case letter, or `to' and a lower case letter: presumably to
- allow extensions whose names may be similar to the existing functions
- declared in <ctype.h>, e.g. `islower' or `toupper').
-
- By the way, we are only talking of symbols with external
- linkage. Unless the appropriate header (<ctype.h> or <string.h> in the
- cases under consideration) is included, the use of these names in
- other contexts (e.g. static functions or variables, block scope
- variables etc.) is perfectly okay.
-
- Technically, the use of a name beiginning with `is' and a lower case
- letter and with external linkage leads to a violation of a `shall'
- condition in the standard, which is outside of any constraint section.
-
- SF: (What kind of ticket would I get for an infraction? Is the implementation required to
- SF: check for this and warn or error?)
-
- It leads to undefined behaviour. So, the compiler is not required to
- give a diagnostic: it may however fail to compile your code, compile
- it and fail to run it to completion, compile and run it with wrong
- results or display a variety of other behviours.
-
- SF:
- SF: Seriously, I will look this up because it seems strange to me and I didn't know
- SF: anything about it. I quick scanned my K&R2 but did not find anything there.
-
- ISO standard: 7.1.3 read in conjunction with 7.13.2. I do not have
- K&R2 handy right now, and do not remember if they go into the
- namespace issues.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-